import heapq
import random
from typing import List

class Solution:
    def findKthLargeest(self,nums:List[int],k:int)->int:
        heap=[]
        for num in nums:
            if len(heap)<k:
                heapq.heappush(heap,num)
            else:
                if num>heap[0]:
                    heapq.heappop(heap)
                    heapq.heappush(heap,num)
        return heap[0]

#随机生成数组
ran_num=random.sample(range(1,1001),100)
k_value=1
solution=Solution()
result=solution.findKthLargeest(ran_num,k_value)
print(f"随机数组是：{ran_num}")
print(f"数组中最大的元素{result}")